<?php

use think\facade\Route;

//miss路由，定义404
Route::miss(function () {
    @header("http/1.1 404 not found");
    @header("status: 404 not found");
    exit();
});
$domain = ['Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With, token, sign'];


Route::get('/', 'index/index')->ext('html');

//首页
Route::group('index', function () {
    Route::get('/index', 'index/index');
    Route::get('/get_openid', 'index/get_openid');
    Route::get('/carousel', 'index/carousel');
    Route::get('/news_reveal', 'index/news_reveal');
    Route::get('/get_cate', 'index/get_cate');
    Route::get('/hot_product', 'index/hot_product');
    Route::get('/recommend', 'index/recommend');
})->allowCrossDomain($domain);

Route::group('login', function () {
    Route::post('/login', 'login/login');
})->allowCrossDomain($domain);

Route::group('callback', function () {
    Route::rule('/wechatCallback', 'callback/wechatCallback');
    Route::rule('/wechatIntegral', 'callback/wechatIntegral');
});

Route::group('news', function () {
    Route::get('/getList', 'news/getList');
    Route::get('/info', 'news/info');
})->allowCrossDomain($domain);

Route::group('product', function () {
    Route::get('/index', 'product/index');
    Route::get('/ProductList', 'product/ProductList')->middleware('verify');
    Route::post('/setCollect', 'product/setCollect')->middleware('verify');
    Route::get('/details', 'product/details')->middleware('verify');;
    Route::get('/payment_method', 'product/payment_method');
    Route::get('/exchange_rules', 'product/exchange_rules');
    Route::get('/comment_list', 'product/comment_list')->middleware('verify');
    Route::post('/submit', 'product/submit')->middleware('verify');
    Route::post('/save', 'product/save')->middleware('verify');
    Route::get('/getHistory', 'product/getHistory')->middleware('verify');
    Route::get('/emptySearch', 'product/emptySearch')->middleware('verify');
    Route::get('/company_phone', 'product/company_phone')->middleware('verify');
    Route::get('/footprint', 'product/footprint')->middleware('verify');
})->allowCrossDomain($domain);

//订单相关
Route::group('order', function () {
    Route::get('/payment', 'order/payment');
    Route::get('/my_order', 'order/my_order');
    Route::get('/my_order_details', 'order/my_order_details');
    Route::get('/getList', 'order/getList');
    Route::get('/success', 'order/success');
    Route::post('/submit', 'order/submit');
    Route::post('/confirmPayment', 'order/confirmPayment');
    Route::post('/edit', 'order/edit');
    Route::post('/refund', 'order/refund');
    Route::get('/reason', 'order/reason');
})->allowCrossDomain($domain)->middleware('verify');

Route::group('user', function () {
    Route::get('/get_user', 'user/get_user');
    Route::post('/edit', 'user/edit');
    Route::post('/get_mobile', 'user/get_mobile');
    Route::get('/collection', 'user/collection');
    Route::get('/warranty', 'user/warranty');
    Route::get('/getUserQrcode', 'user/getUserQrcode');
    Route::get('/wechat', 'user/wechat');
    Route::get('/my_team', 'user/my_team');
    Route::get('/method_index', 'user/method_index');
    Route::get('/method_info', 'user/method_info');
    Route::post('/method_save', 'user/method_save');
    Route::post('/forget', 'user/forget');
})->allowCrossDomain($domain)->middleware('verify');


Route::group('address', function () {
    Route::get('/index', 'address/index');
    Route::get('/add', 'address/add');
    Route::get('/edit', 'address/edit');
    Route::get('/getArea', 'address/getArea');
    Route::post('/save', 'address/save');
    Route::post('/chooseDefault', 'address/chooseDefault');
    Route::post('/delete', 'address/delete');
    Route::post('/choice', 'address/choice');
})->allowCrossDomain($domain)->middleware('verify');

Route::group('account', function () {
    Route::get('/index', 'account/index');
    Route::get('/record/:type', 'account/record');
    Route::get('/getList', 'account/getList');
})->allowCrossDomain($domain)->middleware('verify');

Route::group('uploads', function () {
    Route::rule('/uploadImage', 'uploads/uploadImage');
})->allowCrossDomain($domain);